package de.szut.ita13sommerfeld.blockadventure.gameentities.character;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.LinkedList;

import de.szut.ita13sommerfeld.blockadventure.gameentities.Entity;
import de.szut.ita13sommerfeld.blockadventure.gameentities.Player;
import de.szut.ita13sommerfeld.blockadventure.gameentities.types.PlayerType;
import de.szut.ita13sommerfeld.blockadventure.level.SpawnPoint;

public class Character extends Player {

	public static final float WIDTH = 48;
	public static final float HEIGHT = 96;
	
	public Character(float x, float y, float width, float height, float gravity, SpawnPoint spawnpoint) {
		super(x, y, width, height, spawnpoint,  gravity);
		tex = texture.getPlayerTexture(PlayerType.Player);
	}

	public void render(Graphics g) {
		g.setColor(Color.BLUE);
		g.fillRect((int)x, (int)y, (int)width, (int)height);
	}

	public void tick(LinkedList<Entity> entities) {
		x += velocityX;
		y += velocityY;
		
		if(falling || jumping) {
			velocityY += gravity;
			if(velocityY > MAX_VELOCITY)
				velocityY = MAX_VELOCITY;
		}
		
		controller.checkCollision(this, entities);
		controller.preventGlitchingOutOfBounds(this);
	}
	
	public Rectangle getBounds() {
		return new Rectangle((int)x, (int)y, (int)width, (int)height);
	}

	public Rectangle getBottomBounds() {
		return new Rectangle((int)x + 5, (int)y + (int)(height - 5), (int)width - 10, (int)5);
	}

	public Rectangle getBoundsTop() {
		return new Rectangle((int)x + 5, (int)y, (int)width - 10, (int)5);
	}

	public Rectangle getBoundsRight() {
		return new Rectangle((int)(x + width - 5), (int)y + 5, (int)5, (int)height - 10);
	}

	public Rectangle getBoundsLeft() {
		return new Rectangle((int)x, (int)y + 5, (int)5, (int)height - 10);
	}
}
